######################################

CPP = g++
CFLAG = -c -g
LIBS = -lpthread -lz
INC = -I$(HOME)/workspace/xpie/src/
TESTSRC = test

########################################

PF_OBJS = preforkserver.o shmmanager.o pidsboard.o buffer.o buffersocket.o socket.o epolleventhandler.o epolleventhandlerimpl.o epollmanager.o processor.o log.o resource.o

HTTP_OBJS = httpmsg.o httprequest.o httpresponse.o httpprocessor.o httphandle.o httphandleexecutor.o httphandlefoundfile.o httphandlelastmodified.o  httphandleifmodifiedsince.o date.o codeutil.o httphandlecoding.o characterset.o

TEST_OBJS = testpreforkserver.o testbuffer.o testepollprocs.o testepollprocs2.o testepollmanager.o testhttpprocs.o testlog.o testhttprequest.o testhttpparams.o testresource.o testdate.o testcodeutil.o testhttpspilt_q.o testhttpresponse.o testcharacterset.o

#######################################

PROGS =

TEST = testpreforkserver testbuffer testepollprocs testepollprocs2 testepollmanager testhttpprocs testlog testhttprequest testhttpparams testresource testdate testcodeutil testhttpspilt_q testhttpresponse testcharacterset

#######################################

all : $(TEST) $(PROGS)

testpreforkserver : $(PF_OBJS) testpreforkserver.o
	$(CPP) $(LIBS) -o testpreforkserver $(PF_OBJS) testpreforkserver.o

testbuffer : testbuffer.o buffer.o
	$(CPP) $(LIBS) -o testbuffer testbuffer.o buffer.o

testepollprocs : testepollprocs.o $(PF_OBJS)
	$(CPP) $(LIBS) -o testepollprocs testepollprocs.o $(PF_OBJS)

testepollprocs2 : testepollprocs2.o $(PF_OBJS)
	$(CPP) $(LIBS) -o testepollprocs2 testepollprocs2.o $(PF_OBJS)

testepollmanager : testepollmanager.o $(PF_OBJS)
	$(CPP) $(LIBS) -o testepollmanager testepollmanager.o $(PF_OBJS)

testhttpprocs : testhttpprocs.o $(PF_OBJS) $(HTTP_OBJS)
	$(CPP) $(LIBS) -o testhttpprocs testhttpprocs.o $(PF_OBJS) $(HTTP_OBJS)

testlog : testlog.o log.o
	$(CPP) $(LIBS) -o testlog testlog.o log.o 

testhttprequest : testhttprequest.o $(PF_OBJS) $(HTTP_OBJS)
	$(CPP) $(LIBS) -o testhttprequest testhttprequest.o $(PF_OBJS) $(HTTP_OBJS)

testhttpparams : testhttpparams.o $(PF_OBJS) $(HTTP_OBJS)
	$(CPP) $(LIBS) -o testhttpparams testhttpparams.o $(PF_OBJS) $(HTTP_OBJS)

testresource :  testresource.o buffer.o resource.o
	$(CPP) $(LIBS) -o testresource testresource.o buffer.o resource.o

testdate : testdate.o date.o 
	$(CPP) $(LIBS) -o testdate testdate.o date.o 

testcharacterset : testcharacterset.o characterset.o buffer.o
	$(CPP) $(LIBS) -o testcharacterset testcharacterset.o characterset.o buffer.o

testcodeutil : testcodeutil.o codeutil.o buffer.o 
	$(CPP) $(LIBS) -o testcodeutil testcodeutil.o codeutil.o buffer.o

testhttpspilt_q : testhttpspilt_q.o httprequest.o  httpmsg.o log.o buffer.o
	$(CPP) $(LIBS) -o testhttpspilt_q httprequest.o httpmsg.o log.o testhttpspilt_q.o buffer.o 

testhttpresponse : testhttpresponse.o $(PF_OBJS) $(HTTP_OBJS)
	$(CPP) $(LIBS) -o testhttpresponse testhttpresponse.o $(PF_OBJS) $(HTTP_OBJS)

#######################################

$(HTTP_OBJS) : %.o : %.cpp
	$(CPP) $(CFLAG) $< -o $@

$(PF_OBJS) : %.o : %.cpp
	$(CPP) $(CFLAG) $< -o $@

$(TEST_OBJS) : %.o : $(TESTSRC)/%.cpp
	$(CPP) $(CFLAG) $(INC) $< -o $@

######################################

clean :
	rm -f *.o $(TEST) $(PROGS) core.*
